/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package DAO;

import Model.Connect;
import Pojo.SanPham;
import Pojo.LoaiSanPham;
import Pojo.NhaCungCap;
import Util.HibernateUtil;
import java.sql.Date;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.util.ArrayList;
import java.util.List;
import javax.management.Query;
import org.hibernate.HibernateException;
import org.hibernate.Session;
import org.hibernate.Transaction;

/**
 *
 * @author NTB
 */
public class SupplierDAO {

  Connect cn;

  public static List<NhaCungCap> View() {
    List<NhaCungCap> list = null;
    Session se = HibernateUtil.getSessionFactory().openSession();
    try {
      String sql = "select s from NhaCungCap s";
      org.hibernate.Query qr = se.createQuery(sql);
      list = qr.list();
    } catch (HibernateException e) {
      System.err.print(e);
    } finally {
      se.close();
    }
    return list;
  }
  
  
    public static NhaCungCap GetInfo(int mancc)
    {
        NhaCungCap p_c = null;
        Session se=HibernateUtil.getSessionFactory().openSession();
        try
        {
            p_c = (NhaCungCap) se.get(NhaCungCap.class, mancc);
        }
        catch (HibernateException e)
        {
            e.printStackTrace();
        }
        finally
        {
            se.close();
        }
        return p_c;
    }
    
}
